/* indent size: 1 */

module.exports = app => {
	const DataTypes = app.Sequelize;

	const Model = app.model.define('goods_sku', {
		id: {
			type: DataTypes.INTEGER(8).UNSIGNED,
			allowNull: false,
			primaryKey: true,
			autoIncrement: true
		},
		// 属性组合ids
		composeIds: {
			type: DataTypes.STRING(255),
			allowNull: false,
		},
		// 属性组合names
		composeNames: {
			type: DataTypes.STRING(255),
			allowNull: false,
		},
		// 商品id
		goods_id: {
			type: DataTypes.INTEGER(11),
			allowNull: false,
		},
		cost_price: {
			type: DataTypes.INTEGER(11),
			allowNull: false,
			defaultValue: '0.00',
			comment: '成本价格'
		},
		market_price: {
			type: DataTypes.INTEGER(11),
			allowNull: false,
			defaultValue: '0.00',
			comment: '原价价格（划线价格）'
		},
		price: {
			type: DataTypes.INTEGER(11),
			allowNull: false,
			defaultValue: '0.00',
			comment: '销售价格'
		},
		// 是否在线出售
		online: {
			type: DataTypes.INTEGER(1).UNSIGNED,
			allowNull: true,
			defaultValue: '1'
		},
		// 规格code
		code: {
			type: DataTypes.INTEGER(11),
			allowNull: true,
		},
		shop_id: {
			type: DataTypes.INTEGER(11),
			allowNull: true,
			defaultValue: null,
			comment: '商家ID，预留SASS功能'
		},
		is_delete: {
			type: DataTypes.INTEGER(1).UNSIGNED,
			allowNull: false,
			defaultValue: '0',
			comment: '是否删除，0->存在，1->删除'
		},
	}, {
		tableName: 'goods_sku',
		timestamps: false
	});

	Model.sync({ alter: true });

	Model.associate = function () {
	}

	return Model;
};
